package org.nokatag.tagjava;

import java.io.IOException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

/**
 * 表单自动布局的行
 * @author rebin
 *
 */
public class FormRow extends NokaTag{
	private static final long serialVersionUID = -6266942616787446213L;
	private String style="clear:both;";//style
	private String classstyle=""; //classstyle
	private String id=null; //classstyle
	
	public int doStartTag() throws JspException {
		JspWriter jspOut = pageContext.getOut();
		HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
		StringBuilder bodystr = new StringBuilder();
		bodystr.append(formLayoutCss(request));
		bodystr.append("<div "+(id==null?"":"id=\""+id+"\"")+" style=\""+style+"\" class=\""+classstyle+"\">");
		try {
			jspOut.write(bodystr.toString());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return EVAL_BODY_INCLUDE;
	}
	public int doEndTag() throws JspException {
		try {
			StringBuilder bodystr = new StringBuilder();
			bodystr.append("</div>");
			pageContext.getOut().write(bodystr.toString());
			} catch (IOException e) {
				e.printStackTrace();
			}
		return EVAL_PAGE;
	}
	//--------获取默认宽度---------------------------------
	public String getLabelDefaultwidth(){
		try{
			FormHtml formHtml = (FormHtml)this.getParent();
			return formHtml.getLabeldefaultwidth();
		}catch(Exception se){}
		return null;
	}
	//--------获取默认高度---------------------------------
	public String getLabelDefaultheight(){
		try{
			FormHtml formHtml = (FormHtml)this.getParent();
			return formHtml.getLabeldefaultheight();
		}catch(Exception se){}
		return null;
	}
	//--------获取默认宽度---------------------------------
	public String getInputDefaultwidth(){
		try{
			FormHtml formHtml = (FormHtml)this.getParent();
			return formHtml.getInputdefaultwidth();
		}catch(Exception se){}
		return null;
	}
	//--------获取默认高度---------------------------------
	public String getInputDefaultheight(){
		try{
			FormHtml formHtml = (FormHtml)this.getParent();
			return formHtml.getInputdefaultheight();
		}catch(Exception se){}
		return null;
	}
	public String getStyle() {
		return style;
	}
	public void setStyle(String style) {
		this.style = style;
	}
	public String getClassstyle() {
		return classstyle;
	}
	public void setClassstyle(String classstyle) {
		this.classstyle = classstyle;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}

}
